package com.jxc.model.po;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 盘点单
 * 
 * @author Tino
 * 
 */
@Entity
@Table(name = "KCGL_CHECKLIST")
public class Checklist extends IdEntity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8222532103492127489L;
	/**
	 * 盘点日期
	 * 
	 */
	private Date date;
	/**
	 * 单号
	 * 
	 */
	private String serial;
	/**
	 * 营业员
	 * 
	 */
	private User user;
	/**
	 * 仓库
	 * 
	 */
	private Repertory repertory;
	/**
	 * 是否盘点完
	 * 
	 */
	private Boolean isCheckOver;
	/**
	 * 备注
	 * 
	 */
	private String remark;
	/**
	 * 盘点单明细
	 * 
	 */
	private List<ChecklistItem> checklistItems = new ArrayList<ChecklistItem>();

	public Checklist() {
		super();
	}

	public Checklist(Long id) {
		super(id);
	}

	@Column(name = "DATE")
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Column(name = "SERIAL")
	public String getSerial() {
		return serial;
	}

	public void setSerial(String serial) {
		this.serial = serial;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "USER_ID")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "REPERTORY_ID")
	public Repertory getRepertory() {
		return repertory;
	}

	public void setRepertory(Repertory repertory) {
		this.repertory = repertory;
	}

	@Column(name = "IS_CHECK_OVER")
	public Boolean getIsCheckOver() {
		return isCheckOver;
	}

	public void setIsCheckOver(Boolean isCheckOver) {
		this.isCheckOver = isCheckOver;
	}

	@Column(name = "REMARK")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, mappedBy = "checklist", orphanRemoval = true)
	public List<ChecklistItem> getChecklistItems() {
		return checklistItems;
	}

	public void setChecklistItems(List<ChecklistItem> checklistItems) {
		this.checklistItems = checklistItems;
	}

}
